<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\grid\GridView;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model app\models\AsrPlan */
$this->title = '详情';
$this->params['breadcrumbs'][] = ['label' => 'Asr Plans', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">

<!--        <a class="list-group-item" data-toggle="collapse" href="#usercollapse" aria-expanded="false" aria-controls="collapseExample">用户管理<span class="caret"></span></a>-->
<!--        <div class="collapse" id="usercollapse">-->
<!--            <div class="well">-->
<!--                <div class="list-group">-->
<!--                    <a href="--><?//= Url::toRoute(['asr-plan/index'])?><!--" class="list-group-item">用户列表（gii）</a>-->
<!--                    <a href="--><?//= Url::toRoute(['asr-plan/index'])?><!--" class="list-group-item">用户列表（manual）</a>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <!-- 权限管理 -->
<!--        <a class="list-group-item" data-toggle="collapse" href="#resourcecollapse" aria-expanded="false" aria-controls="collapseExample">资源管理<span class="caret"></span></a>-->
<!--        <div class="collapse" id="resourcecollapse">-->
<!--            <div class="well">-->
<!--                <div class="list-group">-->
<!--                    <a href="--><?//= Url::toRoute(['site/login'])?><!--" class="list-group-item">用户列表（gii）</a>-->
<!--                    <a href="--><?//= Url::toRoute(['asr-plan/index'])?><!--" class="list-group-item">用户列表（gii）</a>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
    <div class="col-lg-1">

    </div>
    <div class="col-lg-6">
        <ul class="nav nav-pills">
            <li role="presentation" class="active"><a href="#">全部用户</a></li>
            <li role="presentation"><a href="index">潜力用户</a></li>
            <li role="presentation"><a href="index">中性用户</a></li>
            <li role="presentation"><a href="/asr-plan/index">拒绝用户</a></li>
            <li role="presentation"><a href="/asr-plan/index">未接通用户</a></li>
        </ul>
    </div>
</div>
<br>
<div class="asr-plan-view">


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            //用户名
            ['attribute'=>'用户名',
                'value'=>function($model){
                   return 'fds';
                }
            ],
            [
                'attribute' => 'created_at',
                'value' => function($model) {
                    return date('Y-m-d H:i:s',$model->created_at);
                }
            ],

            //线路名
            [
                'attribute' => 'line_num',
                'value' => function($model){
                    $line_num = \app\models\AsrCall::find()->select('line,call_id')->where(['call_id'=>$model->call_id])->one();
                    return $line_num['line'];
                    //var_dump(\app\models\AsrCall::find()->where(['call_id'=>$model->call_id])['listname']);
                }
            ],
            //话术名称
            [
                'attribute' => 'audio_name',
                'value' => function($model){
                    $audio_name = \app\models\AsrAudio::find()->select('audio_id,name')->where(['audio_id'=>$model->audio_id])->one();
                    return $audio_name['name'];
                }
            ],
            //电话表
            [
                'attribute' => 'listname',
                'options'=>[
                    'width'=>'10%',
                ],
                'value' => function($model){
                    return   \app\models\AsrMobile::find()->where(['mobile_id'=>$model->mobile_id])->one()['listname'] ;
                }
            ],
            //分类名
            ['attribute' => 'name',
                'options'=>[
                    'width'=>'10%',
                ],
                'value' => function($model){
                    $name = \app\models\AsrAudio::find()->where([ 'audio_id'=>$model->audio_id])->one()['audio_classify_id'];
                    $name = \app\models\AsrAudioClassify::findOne($name)['name'];
                    return $name;
                }

            ],
        ],
//        'filterModel' => $searchModel,
        'showFooter' => true,  //设置显示最下面的footer
        'pager'=>[
            'firstPageLabel'=>"第一页",
            'lastPageLabel'=>'最后一页',
        ],
    ]); ?>
</div>

<script>
    $(function () {
        var Default = {
            animationSpeed: 500,
        }
        //自定义分页
        $("#num").blur(function(){//当鼠标失去焦点时就出发事件，实现分页的页改变
            var url = "index";
            //alert(url);
            $.ajax({
                type:"post",
                async:true,
                cache:false,
                url:url,/*url写异域的请求地址*/
                data:{
                    pageSize:$("#num").val()
                },
                success: function(datas){
                    window.location.reload()
                },
                error: function(error){
                }
            });
        });
    });
</script>

